package com.example.test;

import java.lang.reflect.Field;

public class ReflectClass {
    String name;
    String age;

    public static void main(String[] args) {
        ReflectClass reflectClass = new ReflectClass("zhangsan", "30");
        Class<?> cls = reflectClass.getClass();
        System.out.println(cls.hashCode());
        Field[] fields = cls.getDeclaredFields();
        for (Field t : fields) {
            String name = t.getName();
            System.out.println("" + name);
            try {
                String value = (String) t.get(reflectClass);
                System.out.println("" + value);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    System.out.println("Thread = %d begin" + Thread.currentThread().getId());
                    cls.wait();
                    System.out.println("Thread = %d end" + Thread.currentThread().getId());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("Thread = %d begin" + Thread.currentThread().getId());
                cls.notify();
                System.out.println("Thread = %d end" + Thread.currentThread().getId());

            }
        }).start();
    }

    public ReflectClass(String name, String age) {
        this.name = name;
        this.age = age;
    }
}
